<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Route::post('/login','Auth\LoginController@login');

Route::group(['prefix' => 'admin'], function () {
    Route::get('/', 'Admin\IndexController@index');
    Route::post('/imageUploadOne', 'Admin\UploaderController@imageUploadOne');
    Route::get('/fileupload', 'Admin\UploaderController@fileUpload');
    /*Route::get('/info', 'Admin\IndexController@info');
    Route::any('/test', 'Admin\TestController@index');
    Route::any('/permissionAdd', 'Admin\AdminController@permissionAdd');
    Route::get('/permission', 'Admin\AdminController@permission');
    Route::get('/roles', 'Admin\AdminController@roles');
    Route::get('/users', 'Admin\AdminController@users');
    Route::post('/updatePermission', 'Admin\AdminController@updatePermission');
    Route::post('/imageUploadOne', 'Admin\UploaderController@imageUploadOne');
    Route::get('/fileupload', 'Admin\UploaderController@fileUpload');
    Route::any('/article', 'Admin\ArticleController@article');*/
//    $routes = service('Route')->getAdminRoutes();
//    foreach($routes as $route){
//        if($route['type'] === \App\Permission::$ROUTE_METHOD_ANY){
//            Route::any($route['name'], 'Admin\\'.$route['controller'].'Controller@'.$route['method']);
//        }
//        if($route['type'] === \App\Permission::$ROUTE_METHOD_GET){
//            Route::get($route['name'], 'Admin\\'.$route['controller'].'Controller@'.$route['method']);
//        }
//        if($route['type'] === \App\Permission::$ROUTE_METHOD_POST){
//            Route::post($route['name'], 'Admin\\'.$route['controller'].'Controller@'.$route['method']);
//        }
//        if($route['type'] === \App\Permission::$ROUTE_METHOD_PUT){
//            Route::put($route['name'], 'Admin\\'.$route['controller'].'Controller@'.$route['method']);
//        }
//        if($route['type'] === \App\Permission::$ROUTE_METHOD_DELETE){
//            Route::delete($route['name'], 'Admin\\'.$route['controller'].'Controller@'.$route['method']);
//        }
//    }
});
Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

Route::any('/wechat', 'WechatController@serve'); //微信路由
Route::group(['middleware' => ['web', 'wechat.oauth']], function () {
    Route::get('/user', function () {
        $user = session('wechat.oauth_user'); // 拿到授权用户资料

        dd($user);
    });
});
